package com.sise.wangzhan.controller;

import com.sise.wangzhan.entity.Person;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.awt.*;

/**
 * @Classname PersonController
 * @Description TODO
 * @Date 2020/5/6 15:57
 * @Created by wangzhan
 */
@RestController
public class PersonController {

    @RequestMapping(value = "/person/{personid}",method = RequestMethod.GET
                    ,produces = MediaType.APPLICATION_JSON_VALUE)
    public Person router(@PathVariable("personid") Integer personid, HttpServletRequest request){
        Person person = new Person(personid,"wangzhan",22);
        person.setMessage(request.getRequestURL().toString());

        return person;
    }

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String hello() throws InterruptedException {
        Thread.sleep(800);
        return "hello world";
    }

}
